<template>
  <div>
    <div class="dev-name" @click="openChoose">
      {{devName}}<img class="direct" v-bind:style="{'transform': 'rotate('+ deg +'deg)'}" src="../../assets/img/home/direct.png">
    </div>
    <div v-bind:style="{'height': listHeight + 'rem'}" class="list">
      <div class="dev-part">
        <div
          class="dev-item"
          @click="handle('all', '所有设备')"
          v-bind:class="{'choose':devId==='all'}"
          v-show="showAll === 'true'"
          key="all"
        >
          <div
            class="dev-item-list"
          >所有设备</div>
        </div>
        <div
          class="dev-item"
          v-for="item in devList"
          @click="handle(item.devId, item.devName)"
          v-bind:class="{'choose':devId===item.devId}"
          :key="item.devId"
        >
         <div
           class="dev-item-list"
         >{{item.devName}}</div>
      </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'selectDev',
  props: ['devList', 'isShow', 'showAll'],
  data () {
    return {
      devName: '第二步:选择设备',
      devId: '898602B11116C0068511'
    }
  },
  methods: {
    openChoose: function () {
      this.$emit('changeShow', 'unChange')
    },
    handle: function (devId, devName) {
      this.devId = devId
      this.devName = devName
      this.$emit('changeShow', devId)
    }
  },
  computed: {
    deg: function () {
      if (this.isShow) {
        return 90
      } else {
        return 0
      }
    },
    listHeight: function () {
      if (this.isShow) {
        return 6
      } else {
        return 0
      }
    }
  }
}
</script>

<style scoped>
  @import "../../assets/css/select.css";
  .dev-name {
    height: 0.92rem;
    line-height: 0.92rem;
    font-size: 0.36rem;
    color: #505050;
    padding-left: 0.24rem;
    padding-right: 0.5rem;
    vertical-align: middle;
    background-color: #fff;
  }
  .direct{
    width: 0.17rem;
    height: 0.31rem;
    float: right;
    vertical-align: middle;
    margin-top: 0.29rem;
    transition:transform 1s
  }
  .dev-part {
    width: 7rem;
    height: 4rem;
    margin: 0.1rem auto;
    padding-left: 0.32rem;
    padding-top: 0.4rem;
    background-color: #fff;
    border-radius: 0.1rem;
    overflow-y: scroll;
    box-shadow: 0 0.4rem 0.4rem 0.2rem rgba(183,184,185,0.27);
    font-size: 0;
  }
  .dev-item{
    display: inline-block;
    margin-right: 0.1rem;
    margin-bottom: 0.1rem;
    width: 2.06rem;
    height: 0.62rem;
    border: 1px solid #909192;
    font-size: 0.24rem;
    line-height: 0.62rem;
    text-align: center;
    border-radius: 0.1rem;
  }
  .choose{
    border-bottom: 1px solid #00c0f8;
    background-color: #00c0f8;
    color: #fff;
  }
</style>
